package com.xhlj.security.handler;

import com.xhlj.utils.JwtHelper;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
import org.springframework.stereotype.Component;

import java.io.IOException;

//不需要
@Component
public class CaptchaLoginAuthenticationSuccessHandler implements AuthenticationSuccessHandler {

    @Autowired
    private JwtHelper helper;

    @Override
    public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
//        生成一个Token
//        if (authentication instanceof CaptchaLoginAuthenticationToken) {
//            Map principal = (Map) authentication.getPrincipal();
//            String username = (String) principal.get("phone");
//            Map res = new HashMap();
//            res.put("username", username);
//
//            response.setContentType("application/json;charset=UTF-8");
//            response.getWriter().print(JSON.toJSONString(Result.ok(res)));
//        }


    }
}

